#ifndef __LL_TOKEN_HPP__
#define __LL_TOKEN_HPP__
#include <string>
#include <list>
#include <sstream>
using namespace std;

namespace llmake
{
	typedef struct location
	{
		string 		file;
		int 		line;
		int 		colum;
	} Location;
/// token node
	class llTokenNode;
	typedef list<llTokenNode> llTokenList;
	
	class llTokenNode
	{
// compare 
		friend bool operator == (const llTokenNode &left,const llTokenNode &right)
		{
			return left.m_Token == right.m_Token;
		}
		// members
	public:
		string 					m_Token;		/// token string ,if m_IsGroup=true,m_Token=""
		string 					m_Orignal;		/// token string ,${var} orignal tokens
		Location 				m_Loc;			/// token positions
		int 					m_Id;			/// token id uniform
		bool					m_IsGroup;		/// "akdkkd akkdk kikdkdk " token in "" true;
		bool					m_Joint;		/// joint with token after me.
		llTokenList				m_Group;		///"akdkkd akkdk kikdkdk " token in ""
	};
/// token engine
	class llTokenEngine
	{
// methoda
	public:
		// type = true input = file name
		// type = false input = string stream
		llTokenEngine(string input,bool type=true);
		~llTokenEngine(){}
		/// only for string type token engine
		void setSpilitor(string first,string second)
		{
			if ( false == m_Type )
			{
				m_SpilitFirst = first;
				m_SpilitSecond = second;
			}
		}
		void getToken( llTokenList &tokenList);
	private:
		void getTokenInner( llTokenList &tokenList,
							const string &src,const bool isGroup,
							int &lineCounter);
// members
	private:
		string 					m_Input;
		bool					m_Type;
		stringstream 			m_Stream;
		string 					m_SpilitFirst;
		string 					m_SpilitSecond;
	};
};

#endif // __LL_TOKEN_HPP__
